package com.aifund.app.service.impl;

import com.aifund.app.entity.vo.user.MyInvitationVo;
import com.aifund.app.service.IncomeAndExpenditureService;
import com.aifund.app.service.UserInvitationService;
import com.aifund.app.service.UserService;
import com.aifund.common.enums.config.ConfigEnum;
import com.aifund.common.service.SystemConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IncomeAndExpenditureServiceImpl implements IncomeAndExpenditureService {


    @Autowired
    UserInvitationService userInvitationService;
    @Autowired
    UserService userService;
    @Autowired
    SystemConfigService systemConfigService;

    @Override
    public MyInvitationVo myInvitation(Long userId) {
        //邀请人数
        Integer userInvitationNum = userInvitationService.getUserInvitationNum(userId);
        //今日邀请人数
        Integer userInvitationNumToday = userInvitationService.getUserInvitationNumToday(userId);
        //邀请链接
        String shareUrl = systemConfigService.getByKey(ConfigEnum.SHARE_BASE_URL.getConfigKey()).getConfigValue()+userService.getById(userId).getInvitationCode();
        MyInvitationVo invitationVo = new MyInvitationVo();
        invitationVo.setInvitationNum(userInvitationNum);
        invitationVo.setTodayInvitationNum(userInvitationNumToday);
        invitationVo.setMyShareUrl(shareUrl);
        return invitationVo;
    }

}
